#!/bin/sh

docker stop ruoyi
docker rm ruoyi
docker rmi ruoyi

# 构建镜像：
# 进入到应用目录
# shellcheck disable=SC2164
cd /opt/ruoyi/deploy/docker

echo "Start building docker image of ruoyi."
docker build -f ./Dockerfile -t ruoyi .

# 准备挂载文件
cd /opt/ruoyi

# 运行容器：
echo "Start running docker container of file."
docker run -di --name ruoyi \
-p 8080:8080 \
-v /opt/ruoyi/logs:/opt/ruoyi/logs \
-v /opt/ruoyi/conf:/opt/ruoyi/config \
-v /opt/ruoyi/data/resource:/opt/ruoyi/resource \
--privileged=true \
--restart always \
--log-opt max-size=100m \
--log-opt max-file=10 \
ruoyi

echo "The application ruoyi run completed already!"
echo "You can use command ' docker logs -n 50 ruoyi ' to check the program's startup logs."
